package com.example.myapplication;

import android.annotation.SuppressLint;
import android.net.Uri;

import androidx.annotation.Nullable;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Thing implements Serializable{
    private int id;
    private String name;
    private int count;
    private int unit;
    private int typeFirst;
    private String imagePath;
    private String position;

    private String information;

    private String editDate;
    private long datetime;

    //获取展示用日期字符串
    public String getEditDate() {
        return editDate;
    }
    //获取存储用日期数据
    public long getDatetime() {
        return datetime;
    }
    public Thing(){
        this.id=-1;
    }

    public Thing(int id, String name, int count, int unit, int typeFirst, String imageUri, String position, String information, long datetime) {
        this.id = id;
        this.name = name;
        this.count = count;
        this.unit = unit;
        this.typeFirst = typeFirst;
        this.imagePath = imageUri;
        this.position = position;
        this.information = information;
        this.datetime = datetime;
        setDatetime(datetime);
    }


    public void setDatetime(long datetime) {
        this.datetime = datetime;
        @SuppressLint("SimpleDateFormat") SimpleDateFormat formater = new SimpleDateFormat("yyyy年MM月dd日");
        Date date = new Date(datetime);
        editDate= formater.format(date);
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setUnit(int unit) {
        this.unit = unit;
    }

    public void setTypeFirst(int typeFirst) {
        this.typeFirst = typeFirst;
    }



    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public void setInformation(String information) {
        this.information = information;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public int getCount() {
        return count;
    }

    public int getUnit() {
        return unit;
    }

    public int getTypeFirst() {
        return typeFirst;
    }



    public String getImagePath() {
        return imagePath;
    }

    public String getPosition() {
        return position;
    }

    public String getInformation() {
        return information;
    }

    @Override
    public String toString() {
        return "Thing{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", count=" + count +
                ", unit='" + unit + '\'' +
                ", typeFirst='" + typeFirst + '\'' +
                ", imagePath=" + imagePath +
                ", position='" + position + '\'' +
                ", information='" + information + '\'' +
                ", editDate='" + editDate + '\'' +
                ", datetime=" + datetime +
                '}';
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if(id==((Thing)obj).getId())return true;
        else return false;
    }

    @Override
    public int hashCode() {
        return id;
    }


}
